/*************************************************************************
	> File Name: 006.printf简版实现.c
	> Author: Maureen 
	> Mail: Maureen@qq.com 
	> Created Time: 一  8/23 09:11:28 2021
 ************************************************************************/

#include <stdio.h>

int my_printf(const char *frm, ...) {
    int cnt = 0;
    #define PUTC(a) putchar(a), ++cnt
    for (int i = 0; frm[i]; i++) { //遍历字符串，字符串末尾是'\0'，其对应的ASCII码为0
        PUTC(frm[i]);
    }
    #undef PUTC //代表宏的作用域仅止于此
    return cnt;
}

int main() {
    printf("Hello world\n");
    my_printf("Hello world\n");
    return 0;
}
